import React, { useState, useEffect } from 'react';
import { connect } from 'dva';
import { Image } from 'antd';
import styles from './index.less';

const Static = ({ data, dispatch }) => {
  const [list, setlist]: any = useState([]);
  useEffect(() => {
    dispatch({
      type: '$request/post',
      payload: {
        url: '/api/analysis/v1/examineAnalysis',
        data: {
          page: 0,
          size: 10,
        },
      },
    }).then(res => {
      setlist([
        {
          icon: require('@/images/pic9.png'),
          title: '项目总数',
          data: res.totalCount,
        },
        {
          icon: require('@/images/pic10.png'),
          title: '评审项目数',
          data: res.examineCount,
        },
        {
          icon: require('@/images/pic11.png'),
          title: '评审率',
          data: res.examineRate,
        },
        {
          icon: require('@/images/pic12.png'),
          title: '评审金额（万元）',
          data: res.examineAmount,
        },
        {
          icon: require('@/images/pic13.png'),
          title: '审减金额（万元）',
          data: res.examineReduceAmount,
        },
        {
          icon: require('@/images/pic14.png'),
          title: '审加金额（万元）',
          data: res.examineAddAmount,
        },
      ]);
    });

    return () => {
      setlist([]);
    };
  }, []);
  return (
    <div className={styles.container}>
      {list.map((item, index) => (
        <div key={index} className={styles.item}>
          <Image src={item.icon}></Image>
          <div>
            <div className={styles.title}>{item.title}</div>
            <div className={styles.data}>{item.data}</div>
          </div>
        </div>
      ))}
    </div>
  );
};
export default connect(state => state)(Static);
